package org.example.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * University就是Composite，可以管理College
 */
public class University extends OrganizationComponent{
    
    List<OrganizationComponent> organizationComponents=new ArrayList<OrganizationComponent>();

    public University(String name, String des) {
        super(name, des);
    }


    /**
     * @param organizationComponent 
     */
    @Override
    protected void add(OrganizationComponent organizationComponent) {
        organizationComponents.add(organizationComponent);
    }

    /**
     * @param organizationComponent 
     */
    @Override
    protected void remove(OrganizationComponent organizationComponent) {
        organizationComponents.remove(organizationComponent);
    }


    /**
     * @return
     */
    @Override
    public String getName() {
        return super.getName();
    }

    /**
     * @return
     */
    @Override
    public String getDes() {
        return super.getDes();
    }

    /**
     * 每个子类都需要实现
     * 就是输出包含University的学院信息
     */
    @Override
    public void print() {
        System.out.println("----------" + getName() + "----------"  );
        //遍历list集合
        for (OrganizationComponent organizationComponent : organizationComponents) {
            organizationComponent.print();
        }

    }
}
